from mediator import mediator
from mediator . tests . test_assistant import make_mediator_test_keyword_args

class menu_logic_fake :
    def __init__ ( self ) :
        self . _show_menu = False
        self . _hide_menu = False
        self . _start = False
        self . _configure_title_text_for_menu = None
        self . _configure_next_row_for_menu = None
        self . _on_table_row_click = None
        self . _on_key_down = False
        self . _on_key_up = False
        self . _on_key_return = False
    def show_menu ( self ) :
        self . _show_menu = True
    def hide_menu ( self ) :
        self . _hide_menu = True
    def start ( self ) :
        self . _start = True
    def configure_title_text_for_menu ( self , title_text ) :
        self . _configure_title_text_for_menu = title_text
    def configure_next_row_for_menu ( self , row_text , row_callback ) :
        self . _configure_next_row_for_menu = [ row_text , row_callback ]
    def on_table_row_click ( self , row ) :
        self . _on_table_row_click = row
    def on_key_down ( self ) :
        self . _on_key_down = True
    def on_key_up ( self ) :
        self . _on_key_up = True
    def on_key_return ( self ) :
        self . _on_key_return = True

class arbitrary_module_fake :
    def start ( self ) :
        pass
    def show_menu ( self ) :
        pass
    def hide_menu ( self ) :
        pass
    def on_table_row_click ( self , row ) :
        pass
    def on_key_down ( self ) :
        pass
    def on_key_up ( self ) :
        pass
    def on_key_return ( self ) :
        pass

class mediator_menu_logic_tests : 
    'mediator_menu_logic'
    def __init__ ( self , test ) :
        self . _test = test
        self . _menu_logic = menu_logic_fake ( )
        self . _mediator = mediator ( )
        self . _mediator . register_modules ( ** make_mediator_test_keyword_args \
            ( 'menu_logic' 
            , self . _menu_logic
            , arbitrary_module_fake
            ) )
    def test_start ( self ) :
        self . _mediator . start ( )
        self . _test . assume_true ( self . _menu_logic . _start )
    def test_show_menu ( self ) :
        self . _mediator . show_menu ( )
        self . _test . assume_true ( self . _menu_logic . _show_menu )
    def test_hide_menu ( self ) :
        self . _mediator . hide_menu ( )
        self . _test . assume_true ( self . _menu_logic . _hide_menu )
    def test_configure_title_text_for_menu ( self ) :
        self . _mediator . configure_title_text_for_menu ( 'my title' )
        self . _test . assume_equal ( self . _menu_logic . _configure_title_text_for_menu , 'my title' )
    def test_configure_next_row_for_menu ( self ) :
        self . _mediator . configure_next_row_for_menu ( 'my text' , 'my callback' )
        self . _test . assume_equal ( self . _menu_logic . _configure_next_row_for_menu , [ 'my text' , 'my callback' ] )
    def test_on_table_row_click ( self ) :
        self . _mediator . on_table_row_click ( 'my row' )
        self . _test . assume_equal ( self . _menu_logic . _on_table_row_click , 'my row' )
    def test_on_key_down ( self ) :
        self . _mediator . on_key_down ( )
        self . _test . assume_true ( self . _menu_logic . _on_key_down )
    def test_on_key_up ( self ) :
        self . _mediator . on_key_up ( )
        self . _test . assume_true ( self . _menu_logic . _on_key_up )
    def test_on_key_return ( self ) :
        self . _mediator . on_key_return ( )
        self . _test . assume_true ( self . _menu_logic . _on_key_return )
